<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Calculate Your Mathematic Expression</title>
<script type="text/javascript" src="/static/script/ajax.js"></script>
</head>

<body>
 <p>Input your arithmetic expression below, click the &quot;Calculate&quot; button and you will get your answer!
 <p>
 <table width="200" border="0">

   <tr>
     <td colspan="3" align="left"><textarea cols="50" rows="10" id="area_expr" >1+2</textarea></td>
     <td valign="bottom"><button id="btn_calc" disabled="disabled" onclick="func_calc('area_expr','div_result')">Loading...</button></td>
   </tr>
   <tr>
     <td width="10" align="left" style="padding-left:5px;">&gt;&gt;</td>
     <td align="left" style="border-bottom:1px #660000 dashed"><div id="div_result">&nbsp;</div></td>
     <td width="50" >&nbsp;</td>
     <td></td>
   </tr>
 </table>
<p>


</body>

<script language="javascript">

// enable button
setTimeout(
function(){
document.getElementById("btn_calc").disabled = "";
document.getElementById("btn_calc").innerHTML = "Claculate";
},200);


function func_calc(id_expr,id_result){
	document.getElementById("btn_calc").disabled = "disabled";
	document.getElementById("btn_calc").innerHTML = "Claculating...";
	Ajax.sendGET("/calculator/calcexpr",{"math_expr":document.getElementById(id_expr).value},
	function(resp){
		document.getElementById(id_result).innerHTML = resp;
	},
	function(errcode){
		document.getElementById(id_result).innerHTML = "Error: "+errcode;
	},
	function(){
		document.getElementById("btn_calc").disabled = "";
		document.getElementById("btn_calc").innerHTML = "Claculate";
	}
	);
}

</script>


</html>
